package rkw.database.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

import core.communication.message.MessageType;
import core.database.AbstractEntity;

@Entity
@Table(name = "messageReceived")
public class MessageReceived extends AbstractEntity {
	@Column(name = "type", nullable = false)
	@Enumerated(EnumType.STRING)
	private MessageType type;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created", nullable = false)
	private Date created;

	@Type(type = "text")
	private String value;

	@Column(name = "isHandled")
	private Boolean isHandled = false;

	public MessageType getType() {
		return type;
	}

	public void setType(MessageType type) {
		this.type = type;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public Boolean getIsHandled() {
		return isHandled;
	}

	public void setIsHandled(Boolean isHandled) {
		this.isHandled = isHandled;
	}

	@PrePersist
	protected void onCreate() {
		created = new Date();
	}
}
